/**
 * Created by dell4 on 2016/5/18.
 */

(function (){

    /*导入页面样式*/
    yepnope({
        load: [
            '../../assets/ace/css/ace-ie.min.css',
            '../../assets/ace/css/ace.min.css',
            '../../assets/font-awesome/css/font-awesome.min.css',
            '../../assets/datatables/css/jquery.dataTables.min.css',
            '../../assets/bootstrap/css/bootstrap.min.css',
            '../../assets/ztree/css/metroStyle/metroStyle.css',
            '../../assets/bootstraptime/css/bootstrap-datetimepicker.min.css',
            '../../common/css/public.css',
            '../../common/css/base.css',
            '../../common/css/common.css'
        ]
    });

    //设置left页面的全局高度铺满全屏
    window.onload=function(){
        setTimeout(function(){
            setDocument()
        },200)

    }
    window.onresize=function(){
        setDocument()
    }

    var JPlaceHolder = {
        //检测
        _check : function(){
            return 'placeholder' in document.createElement('input');
        },
        //初始化
        init : function(){
            if(!this._check()){
                this.fix();
            }
        },
        //修复
        fix : function(){
            jQuery(':input[placeholder]').each(function(index, element) {
                var self = $(this), txt = self.attr('placeholder');
                self.wrap($('<div></div>').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'}));
                var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left');
                var holder = $('<span></span>').text(txt).css({position:'absolute', left:pos.left, top:pos.top, height:h, lienHeight:h, paddingLeft:paddingleft, color:'#aaa'}).css("line-height",""+h+"px").css("font-size","14px").appendTo(self.parent());
                if(self.val()!=""){
                    holder.hide();
                }
                self.focusin(function(e) {
                    holder.hide();
                }).focusout(function(e) {
                    if(!self.val()){
                        holder.show();
                    }

                });
                holder.click(function(e) {
                    holder.hide();
                    self.focus();
                });
            });
        }
    };
    //执行
    jQuery(function(){
        JPlaceHolder.init();
    });

//    $("body").append("<div class='shouqi' title='点击收起'> << </div>")

    $(document).on("click",".setTopnav li",function(){
        $(this).parent().find("li").removeClass("class_add");
        $(this).addClass("class_add");
    })

    //ajax点击不同按钮载入不同页面内容

    $(document).on("click",".user_ziji",function(){
        $(this).parent().find(".user_ziji").removeClass("user_zijiclass")
        $(this).addClass("user_zijiclass")
    })



    $(".user_fuji").click(function(){
        if( $(this).hasClass("jt_right"))
        {
            $(this).removeClass("jt_right");
            $(this).addClass("jt_down");
        }else
        {
            $(this).addClass("jt_right");
            $(this).removeClass("jt_down");
        }
        if( $(this).next().hasClass("ziji_ul"))
        {
            $(this).next().fadeToggle(100);
        }
    })

    $(".shouqi").click(function(){
        if($(this).hasClass("zk"))
        {
            $(this).removeClass("zk");
            $(".user_cention_left").fadeIn(0);
            $(this).css("left","200px");
            $(this).html("<<")
            $(this).attr("title","点击收起");
            var wWidth=$(window).width();
            var wWidththis=wWidth-194;
            $(".user_cention_right").css("width",""+wWidththis+"px");

        }else
        {
            $(this).addClass("zk");
            $(".user_cention_left").fadeOut(0);
            $(this).css("left","0px");
            $(this).html(">>")
            $(this).attr("title","点击展开");
            var wWidth=$(window).width();
            var wWidththis=wWidth-10;
            $(".user_cention_right").css("width",""+wWidththis+"px");
        }
    })
})()

//回调遍历屏幕自适应
function setDocument()
{
    setHeightleft("user_cention_left");
    setHeightleft("user_cention_right");
    setWidthleft("user_cention_right");
    setHeightleft2("widget-body",240)
}






//设置left页面的全局高度铺满全屏
function setHeightleft(className){
    var wHeight=$(window).height();
    var wHeightthis=wHeight-50;
    $("."+className+"").css("height",""+wHeightthis+"px");
}
function setHeightleft2(className,setHeight){
    var wHeight=$(window).height();
    var wHeightthis=wHeight-setHeight;
    $("."+className+"").css("height",""+wHeightthis+"px");
}
function setWidthleft(className){
    var wWidth=$(window).width();
    var wWidththis=wWidth-194;
    $("."+className+"").css("width",""+wWidththis+"px");
}

